//
//  TXCNetLog.swift
//  Demo
//
//  Created by ryan on 2021/8/23.
//

import Foundation

protocol TXCNetLogProtocol: NSObjectProtocol {
    func requetBefore(path: String, parameter: [String: Any]?)
    func requetAfter(path: String, response: HTTPURLResponse?, resultData: Data?)
}


class TXCNetLog: NSObject, TXCNetLogProtocol {
    func requetBefore(path: String, parameter: [String : Any]?) {
		#if DEBUG
        print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
        print("请求开始之前 \n 路径:", path, "\n 参数:", parameter as Any)
		print("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
		#endif
    }
    
    func requetAfter(path: String, response: HTTPURLResponse?, resultData: Data?) {
		#if DEBUG
		print("------------------------------------------------------------")
		var result: Any = ""
		if let data = resultData {
			try? result = JSONSerialization.jsonObject(with: data, options: .mutableContainers)
		}
        print("请求结束之后 \n 路径:", path, "\n 响应格式:", response as Any, "\n 响应结果:", result)
        print("------------------------------------------------------------")
		#endif
    }
}





